/*package palidino76.rs2.io.packets;

import palidino76.rs2.player.items.PlayerItems;
import palidino76.rs2.Engine;
import palidino76.rs2.util.Misc;
import palidino76.rs2.player.Player;
import palidino76.rs2.player.items.*;
import palidino76.rs2.player.*;
import palidino76.rs2.npcs.NPC;
import palidino76.rs2.io.*;
import palidino76.rs2.Server;


public class ItemOnNPC {
 
    /**
     * Handles using an item on an NPC.
     * @param p The Player which the frame should be handled for.
     * @param packetId The packet id this belongs to.
     * @param packetSize The amount of bytes being recieved for this packet.
     */
    /*public void handlePacket(Player p, int packetId, int packetSize) {
        if (p == null || p.stream == null) {
            return;
        }
		int itemId = p.stream.readUnsignedWordA();
		int npcSlot = p.stream.readUnsignedWordA();
		int randomIndex = p.stream.readUnsignedWordA();
		int interfaceId = p.stream.readUnsignedWordA();
        int junk = p.stream.readDWord();
        p.clickId = p.stream.readUnsignedWord();
        int itemSlot = p.stream.readUnsignedWordBigEndianA();
		int npcId = p.stream.readUnsignedWordA();
        NPC n = Engine.npcs[p.clickId];
		PlayerItems pi = new PlayerItems();
        switch(npcSlot) {
        case 6528://add yours case
			if (itemId == 6570) {
				Server.engine.playerItems.deleteItem(p, 6570, Server.engine.playerItems.getItemSlot(p, 6570), 1);
				Server.engine.playerItems.addItem(p, 4718, 1);
				Server.engine.playerItems.addItem(p, 4716, 1);
				Server.engine.playerItems.addItem(p, 4720, 1);
				Server.engine.playerItems.addItem(p, 4722, 1);
				p.frames.showChatboxInterface(p, 241);
				p.frames.animateInterfaceId(p, 6528, 241, 2);
				p.frames.setNPCId(p, 4285, 241, 2);
				p.frames.setString(p, "Grand Exchange Clerk", 241, 3);
				p.frames.setString(p, "Here's your Dharok's set.", 241, 4);
				p.NpcDialogue = 0;
				p.NpcDialogueSend = true;
			}
			break;
        	default:
        		p.requestFaceTo(p.clickId);
        		Misc.println("["+p.username+"]: Item on NPC: NPC:"+p.clickId+" Item:"+itemId);
        	break;
		}
	}
}*/
package palidino76.rs2.io.packets;

import palidino76.rs2.player.items.PlayerItems;
import palidino76.rs2.Engine;
import palidino76.rs2.util.Misc;
import palidino76.rs2.player.Player;
import palidino76.rs2.player.items.*;
import palidino76.rs2.player.*;
import palidino76.rs2.npcs.NPC;
import palidino76.rs2.io.*;
import palidino76.rs2.Server;

public class ItemOnNPC implements Packet {
    public void handlePacket(Player p, int packetId, int packetSize) {
        if (p == null || p.stream == null) {
            return;
        }
        
        int junk = p.stream.readDWord();
        p.clickId = p.stream.readUnsignedWord();
        int itemSlot = p.stream.readUnsignedWordBigEndianA();
        int itemId = p.stream.readUnsignedWordA();
		int npcId = p.stream.readUnsignedWordA();
        NPC npc = Engine.npcs[p.clickId];
        switch(itemId) {
		case 6570: // Item ID
			if(npcId == 6528) { // NPC ID
              	Server.engine.playerItems.deleteItem(p, 6570, Server.engine.playerItems.getItemSlot(p, 6570), 1);
				Server.engine.playerItems.addItem(p, 4718, 1);
				Server.engine.playerItems.addItem(p, 4716, 1);
				Server.engine.playerItems.addItem(p, 4720, 1);
				Server.engine.playerItems.addItem(p, 4722, 1);
				p.frames.showChatboxInterface(p, 241);
				p.frames.animateInterfaceId(p, 6528, 241, 2);
				p.frames.setNPCId(p, 4285, 241, 2);
				p.frames.setString(p, "Grand Exchange Clerk", 241, 3);
				p.frames.setString(p, "Here's your Dharok's set.", 241, 4);
				p.NpcDialogue = 0;
				p.NpcDialogueSend = true;
        }
        break;
        	default:
        		p.requestFaceTo(p.clickId);
        		Misc.println("["+p.username+"]: Item on NPC: NPC:"+p.clickId+" Item:"+itemId);
        	break;
        }
    }
}